{extend name='admin@public/content'}

{block name="content"}
<form autocomplete="off" onsubmit="return false;" action="{:request()->url()}" data-auto="true" method="post" class='form-horizontal layui-form padding-top-20'>

    <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
        <ul class="layui-tab-title">
            <li class="layui-this">基本信息</li>
            {eq name="vo['type']" value="$Think.const.USER_TYPE_WORKER"}
                <li>工人邦信息</li>
            {/eq}
            {eq name="vo['type']" value="$Think.const.USER_TYPE_SUPPLIER"}
                <li>供应商信息</li>
            {/eq}
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <div class="form-group">
                    <label class="col-sm-2 control-label">手机号</label>
                    <div class='col-sm-8'>
                        <input autofocus name="phone" value='{$vo.phone|default=""}' required="required" title="请输入手机号" placeholder="请输入手机号" class="layui-input">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">昵称</label>
                    <div class='col-sm-8'>
                        <input name="nickname" value='{$vo.nickname|default=""}' required="required" title="请输入昵称" placeholder="请输入昵称" class="layui-input">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">标签</label>
                    <div class='col-sm-8'>
                        {assign name="flag_arr" value="$Think.const.FLAG_ARR" /}
                        {foreach $flag_arr as $flag_key=>$flag }
                        <label class="think-checkbox"><input lay-ignore class="list-check-box" type="checkbox" {in name="flag_key" value="$vo['flag']|default=''"}checked{/in} value="{$flag_key}" name="flag[]"/> {$flag}</label>
                        {/foreach}
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">性别</label>
                    <div class='col-sm-8'>
                        <label class="think-radio"><input lay-ignore type="radio" {$vo['sex']=='男'?'checked':''} value="男" name="sex"/> 男</label>
                        <label class="think-radio"><input lay-ignore type="radio" {$vo['sex']=='女'?'checked':''} value="女" name="sex"/> 女</label>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">实地认证</label>
                    <div class='col-sm-8'>
                        <label class="think-radio"><input lay-ignore type="radio" {$vo['real_address']=='1'?'checked':''} value="1" name="real_address"/> 是</label>
                        <label class="think-radio"><input lay-ignore type="radio" {$vo['real_address']=='0'?'checked':''} value="0" name="real_address"/> 否</label>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">选择区域</label>
                    <div class='col-sm-2'>
                        <select name="province" required="required" data-value="{$vo.province|default=''}" lay-filter="province">
                            <option value="0">请选择</option>
                        </select>
                    </div>
                    <div class='col-sm-2'>
                        <select name="city" data-value="{$vo.city|default=''}" lay-filter="city">
                            <option value="0">请选择</option>
                        </select>
                    </div>
                    <div class='col-sm-2'>
                        <select name="district" data-value="{$vo.district|default=''}" lay-filter="district">
                            <option value="0">请选择</option>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">详细地址</label>
                    <div class='col-sm-8'>
                        <input value="{$vo.address|default=''}" class="layui-input" name="address"/>
                        <input type="hidden" name="lng" value="{$vo.lng|default=''}"/>
                        <input type="hidden" name="lat" value="{$vo.lat|default=''}"/>
                        <a href="javascript:;" class="js_map_btn">地图</a>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">排序</label>
                    <div class='col-sm-8'>
                        <input name="sort" value='{$vo.sort|default="0"}' required="required" title="请输入排序值" placeholder="请输入排序值" class="layui-input">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label label-required">会员头像</label>
                    <div class='col-sm-8'>
                        <table class="layui-table background-item margin-none" lay-size="sm" lay-skin="nob">
                            <thead>
                            <tr>
                                <td>会员头像</td>
                            </tr>
                            </thead>
                            <tbody>
                            <tr>
                                <td class="text-top" style="width:100px">
                                    <input type="hidden" name="headimg" value="{$vo.headimg|default=''}">
                                    <script>$('[name=headimg]').uploadOneImage()</script>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            <div class="layui-tab-item">
                <!--工人邦信息-->
                {eq name="vo['type']" value="$Think.const.USER_TYPE_WORKER"}

                <div class="form-group">
                    <label class="col-sm-2 control-label">姓名</label>
                    <div class='col-sm-8'>
                        <input name="name" value='{$vo.worker_info.name|default=""}' required="required" title="请输入姓名" placeholder="请输入姓名" class="layui-input">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">工种</label>
                    <div class='col-sm-8'>
                        <label class="layui-input no_border" style="height: auto;">
                            {foreach $my_cate as $cate}
                            <label class="think-checkbox"><input lay-ignore class="list-check-box onecate" type="checkbox" {in name="cate.id" value="$vo.worker_info.work_type_ids"}checked{/in}  value="{$cate.id}" name="work_type_ids[]"/> {$cate.title}</label>
                            {/foreach}
                        </label>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">技能</label>
                    <div class='col-sm-8'>
                        <label class="layui-input no_border js_two_cate_box" style="height: auto;">
                        </label>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">工价</label>
                    <div class='col-sm-8'>
                        <input type="number" step="0.01" name="work_price" value='{$vo.worker_info.work_price|default=""}' required="required" title="请输入工价" placeholder="0.00" class="layui-input">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">生日</label>
                    <div class='col-sm-8'>
                        <input name="birthday" value='{$vo.worker_info.birthday|default=""|date='Y-m-d'}' required="required" title="请选择生日" placeholder="请选择生日" class="layui-input">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">个人擅长</label>
                    <div class='col-sm-8'>
                        <input name="good_at" value='{$vo.worker_info.good_at|default=""}' required="required" title="请输入个人擅长" placeholder="请输入个人擅长" class="layui-input">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">过期时间</label>
                    <div class='col-sm-8'>
                        <input name="expiry_time" value="{$vo.worker_info.expiry_time|default=''|date='Y-m-d H:i:s'}" required="required" title="请选择过期时间" placeholder="请选择过期时间" class="layui-input">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">入驻等级</label>
                    <div class='col-sm-8'>
                        <select required class="layui-select full-width" name="grade_id">
                            {foreach $store_member_grade as $grade}
                            <option {eq name="grade['id']|default=''" value="$vo['worker_info']['grade_id']|default=0"}selected{/eq} value="{$grade.id}">{$grade.name}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
                {/eq}
                <!--供应商信息-->
                {eq name="vo['type']" value="$Think.const.USER_TYPE_SUPPLIER"}

                <div class="form-group">
                    <label class="col-sm-2 control-label">供应商名称</label>
                    <div class='col-sm-8'>
                        <input name="name" value='{$vo.supplier_info.name|default=""}' required="required" title="请输入供应商名称" placeholder="请输入供应商名称" class="layui-input">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">座机号</label>
                    <div class='col-sm-8'>
                        <input name="tel" value='{$vo.supplier_info.tel|default=""}' title="请输入座机号" placeholder="请输入座机号" class="layui-input">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">企业概况</label>
                    <div class='col-sm-8'>
                        <textarea class="layui-textarea" name="intro" placeholder="请输入企业概况">{$vo.supplier_info.intro|default=''}</textarea>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">从事行业</label>
                    <div class='col-sm-8'>
                        <label class="layui-input no_border" style="height: auto;">
                            {foreach $my_cate as $cate}
                            <label class="think-checkbox"><input lay-ignore class="list-check-box onecate" type="checkbox" {in name="cate.id" value="$vo.supplier_info.supplier_type_ids"}checked{/in}  value="{$cate.id}" name="supplier_type_ids[]"/> {$cate.title}</label>
                            {/foreach}
                        </label>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">主营范围</label>
                    <div class='col-sm-8'>
                        <label class="layui-input no_border js_two_cate_box" style="height: auto;">
                        </label>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label label-required">简介图片</label>
                    <div class='col-sm-8'>
                        <table class="layui-table background-item margin-none" lay-size="sm" lay-skin="nob">
                            <thead>
                            <tr>
                                <td>图片</td>
                            </tr>
                            </thead>
                            <tbody>
                            <tr>
                                <td class="text-top">
                                    <input type="hidden" name="images" value="{$vo.supplier_info.images|default=''}">
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                <script>
                    $('input[name="images"]').uploadMultipleImage();
                </script>

                <div class="form-group">
                    <label class="col-sm-2 control-label">过期时间</label>
                    <div class='col-sm-8'>
                        <input name="expiry_time" value="{$vo.supplier_info.expiry_time|date='Y-m-d H:i:s'}" required="required" title="请选择过期时间" placeholder="请选择过期时间" class="layui-input">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">入驻等级</label>
                    <div class='col-sm-8'>
                        <select required class="layui-select full-width" name="grade_id">
                            {foreach $store_member_grade as $grade}
                            <option {eq name="grade['id']" value="$vo['supplier_info']['grade_id']|default=0"}selected{/eq} value="{$grade.id}">{$grade.name}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
                {/eq}
            </div>
        </div>
    </div>

    <div class="hr-line-dashed"></div>

    <div class="col-sm-7 col-sm-offset-2">
        <div class="layui-form-item text-center">
            {if !empty($vo.id)}
            <input type="hidden" name="id" value="{$vo.id}">
            <input type="hidden" name="type" value="{$vo.type}">
            {/if}
            <button class="layui-btn" type="submit">保存</button>
            <button class="layui-btn layui-btn-danger" type='button' onclick="window.history.back()">取消</button>
        </div>
    </div>

    <style>
        .background-item {
            padding: 15px;
            background: #efefef;
        }
        .no_border{border:none;}
        .background-item thead tr {
            background: #e0e0e0
        }
    </style>
    <script>
        window.form.render();
        layui.use('laydate', function(){
            var laydate = layui.laydate;

            laydate.render({
                elem: 'input[name=birthday]',
                btns: ['now', 'confirm']
            });
            laydate.render({
                elem: 'input[name=expiry_time]',
                type: 'datetime',
                btns: ['now', 'confirm']
            });
        });
        $(function(){
            $('.js_map_btn').click(function () {
                layer.open({
                    type: 2,
                    area: ['700px', '400px'],
                    fixed: false, //不固定
                    maxmin: false,
                    content: '{:url("choose_position")}?address='+$('input[name=address]').val()
                });
            });
        })
    </script>

    {if $vo['type']>0}
    <script>
        $(function(){
            show_two_cate();
            //点击事件
            $('input.onecate').click(function(){
                show_two_cate();
            });
        });
        //初始化
        function show_two_cate(){
            var _str=get_cate_one();
            var skill="{$two_cate_ids},";
            if(_str){
                //获取下级分类
                $.get('/api/other.system/my_cate_list',{pid:_str},function(res){
                    var data=res.data;
                    var _html='';
                    var _checked;
                    $.each(data,function (index,obj) {
                        _checked='';
                        if(skill.indexOf(obj.id) != -1){
                            _checked="checked";
                        }
                        _html+='<label class="think-checkbox">' +
                            '<input lay-ignore class="list-check-box twocate" '+_checked+' type="checkbox" value="'+(obj.id)+'" name="skill[]"/>'+(obj.title)+
                            '</label>'
                    });
                    $('.js_two_cate_box').html(_html);
                });
            }
        }
        function get_cate_one(){
            var result='';
            $("input.onecate:checked").each(function(index,obj){
                if(result){
                    result+=','+$(obj).val();
                }else{
                    result=$(obj).val();
                }

            });
            return result;
        }
    </script>
    {/if}
</form>
{/block}
{block name='script'}
<script src="__STATIC__/citylist.js"></script>
{/block}
{block name='style'}
<style>
    .js_map_btn{position: absolute;right: 25px;top: 7px;text-decoration: none;}
</style>
{/block}
